﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>抄送</title>
    <!--
    1, 退回界面。
    2，需要 FK_Flow, FK_Node,WorkID, FID.
    3, 调用方法 CC.htm?FK_Flow=001&FK_Node=103&WorkID=232&FID=23
    -->
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/components-rounded.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/themes/default/style.min.css" rel="stylesheet" />
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/QueryString2016.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.cokie.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <link href="../../DataUser/Style/Table0.css" rel="Stylesheet" />
    <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>

    <style type="text/css">
        body
        {
            background: transparent;
        }
        body div
        {
            text-align: left;
        }
        #Message
        {
            width: 100%;
        }
        
        #SelectEmp
        {
            position: relative;
            width: 400px;
            border-top: 0;
            display: none;
            margin-top: -7px; /*border: solid 2px #3175af;*/
        }
        
        .item
        {
            padding: 3px 5px;
            cursor: pointer;
            float: left;
            width: 190px;
            line-height: 20px;
            display: inline-block;
            background-color: #F7F7F7;
        }
        
        #next
        {
            float: left;
            position: relative;
            width: 600px;
        }
        
        .addbg
        {
            background: #CFCFCF;
        }
    </style>
    <script type="text/javascript">
        var param = {};
        $(function () {

            Help();

            //初始化页面移交页面
            param = {
                FK_Node: GetQueryString('FK_Node'),
                WorkID: GetQueryString('WorkID'),
                FID: GetQueryString('FID'),
                Message: GetQueryString('Info'),
                FK_Flow: GetQueryString("FK_Flow")
            };

            $('#Msg').val(param.Message);

            //初始化人员选择窗口
            var selectEmpModalHtml = '<div class="modal fade" id="selectEmpsModal">' +
               '<div class="modal-dialog">'
                   + '<div class="modal-content" style="border-radius:0px;width:700px;">'
                      + '<div class="modal-header">'
                          + '<button type="button" class="close" style="color:white;opacity:1;" data-dismiss="modal" aria-hidden="true">&times;</button>'
                           + '<h4 class="modal-title">选择抄送人</h4>'
                       + '</div>'
                       + '<div class="modal-body">'
                           + '<iframe style="width:100%;border:0px;height:400px;" id="iframeSelectEmpsForm" name="iframeSelectEmpsForm"></iframe>'
                       + '</div>'
                   + '</div><!-- /.modal-content -->'
               + '</div><!-- /.modal-dialog -->'
           + '</div>';

            $('body').append($(selectEmpModalHtml));
            var dept = getQueryStringByNameFromUrl("?" + $.cookie('CCS'), "FK_Dept");
            if (dept == null || dept == '' || dept == undefined) {
                dept = $.cookie('FK_Dept');
            }
            if (dept == undefined) {
                var u = new WebUser();
                dept = u.FK_Dept;
            }
            var url = "SelectEmps.htm?FK_Dept=" + dept + "&FK_Node=" + GetQueryString("FK_Node") + "&s=" + Math.random();
            //  url = url.replace('101', '10102');
            url = url.replace('=101&', '=10102&');

            $('#iframeSelectEmpsForm').attr('src', url);
            $('#Btn_SelectEmps').bind('click', function () { $('#selectEmpsModal').modal().show(); });
            //$("section").show();
            $(".Msg").hide();



            //查询出来抄送的信息.
            var ccs = new Entities("BP.WF.Template.CCLists");
            ccs.Retrieve("FK_Node", GetQueryString("FK_Node"), "WorkID", GetQueryString("WorkID"));

            BindTable(ccs);

        });

        function BindTable(ccs) {

            for (var i = 0; i < ccs.length; i++) {

                var cc = ccs[i];

                var row = "";
                row += "<tr>";
                // row += "<td>" + i + "</td>";
                row += "<td>" + cc.CCTo+"," + cc.CCToName + "</td>";
                row += "<td  title='" + cc.CCToDeptName + "' >" + cc.CCToDeptName + "</td>";

                row += "<td><a href=\"javascript:DeleteIt('" + cc.MyPK + "'," + i + ");\" >移除</a></td>";

                row += "</tr>";

                //$("#Table1 tr:last").after(row);
                $("#Table1 tbody").append(row);
            }
        }

        function DeleteIt(mypk, row) {

            var cc = new Entity("BP.WF.Template.CCList");
            cc.MyPK = mypk;
            cc.Delete();
            window.location.href = window.location.href;
            return;

            //delRow(row); //清空单个table tbody
            ClearTable();

            // 把返回的结果，重新绑定.
            var sas = JSON.parse(data);
            BindTable(sas);
            return;
        }


        //确定  执行抄送操作
        function DoCC(empStr) {

            var workID = GetQueryString("WorkID");

            var webUser = new WebUser();

            var emp = new Entity("BP.Port.Emp", empStr);

            var empName = emp.Name;
            var empDeptNo = emp.FK_Dept;
            var empDeptName = emp.FK_DeptText;

            var gwf = new Entity("BP.WF.GenerWorkFlow", workID);

            var title = gwf.Title;
            var nodeName = gwf.NodeName;
            var flowName = gwf.FlowName;
                         
            var cc = new Entity("BP.WF.Template.CCList");

            //当前人员的信息.
            cc.Rec = webUser.No;
            cc.RecName = webUser.Name;

            //抄送给人员的信息.
            cc.CCTo = empStr;
            cc.CCToName = empName;

            cc.FK_Node = GetQueryString("FK_Node");
            cc.WorkID = GetQueryString("WorkID");

            cc.MyPK = cc.WorkID + "_" + cc.FK_Node + "_" + cc.CCTo;

            if (cc.IsExits() == true) {
                alert('该人员[' + cc.CCToName + ']已经存在.');
                return;
            }

            //抄送给部门的信息.
            cc.CCToDept = empDeptNo;
            cc.CCToDeptName = empDeptName;

            cc.WorkID = GetQueryString("WorkID");
            cc.FK_Node = GetQueryString("FK_Node");

            cc.NodeName = nodeName;
            cc.FK_Flow = GetQueryString("FK_Flow");
            cc.FlowName = flowName;
            cc.Title = title;

            //cc.PWorkID = gwf.PWorkID;
            //cc.PFlowNo = gwf.PFlowNo;

               cc.MyPK = cc.WorkID + "_" + cc.FK_Node + "_" + cc.CCTo;

            //cc.pkval = cc.MyPK;
            //emp.SetPKVal(cc.MyPK);
            if (cc.IsExits() == true) {
                alert('该人员已经存在.');
                return;
            }

            cc.Insert();

            window.location.href = window.location.href;

            $(".foot").hide();
        }

        //确定后，就弹出选择到达节点，选择接受人，填写审核意见窗口.
        function SaveAndClose() {

            // var url = "CCToNodes.htm?WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow") + "&FK_Node=" + GetQueryString("FK_Node");
            // window.location.href = url;
            // return;

            var toNode = GetQueryString("ToNode");
            if (toNode == undefined || toNode == "undefined")
                toNode = "0";

            $("#Btn_CC").attr("disabled", "disabled");
            $("#Btn_CC").val("执行中...");
            $("#Btn_SelectEmps").attr("disabled", "disabled");


            //执行数据初始化工作.
            var hand = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            hand.AddUrlData();
            var data = hand.DoMethodReturnString("CC_SaveAndClose");

            if (data.indexOf('url@') == 0) {
                data = data.replace('url@', '');
                window.location.href = data;
                return;
            }

            //如果需要发送,就执行发送.
            if (data.indexOf('Send@') == 0) {
                SendIt();
                return;
            }

            //提示信息后关闭窗口.
            if (data.indexOf('close@') == 0) {

                alert(data.replace('close@', ''));

                if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                    window.parent.returnWorkWindowClose("");
                    window.parent.close();

                } else {

                    $('body').append($('<div>' + "已取消操作" + '</div>'));

                    window.close();
                }
                return;
            }

            //提示信息.
            if (data.indexOf('info@') == 0) {
                alert(data.replace('info@', ''));

                $("#Btn_CC").attr("disabled", false);
                $("#Btn_CC").val("执行抄送");
                $("#Btn_SelectEmps").attr("disabled", false);

                return;
            }

            alert(data);
            window.close();
            return;
        }

        //执行发送.
        function SendIt() {

            //执行数据初始化工作.
            var hand = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            hand.AddUrlData();
            var data = hand.DoMethodReturnString("AccepterOfGener_Send");

            if (data.indexOf('err@') == 0) {
                $(".Msg").show();
                $(".Msg").html(data);
                return;
            }

            data = data.replace("'MyFlowInfo", "'../MyFlowInfo");
            data = data.replace("'MyFlow.htm", "'../MyFlow.htm");
            data = data.replace("'MyFlow.htm", "'../MyFlow.htm");

            data = data.replace("'WFRpt", "'../WFRpt");
            data = data.replace("'WFRpt", "'../WFRpt");

            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");

            data = data.replace("'./WorkOpt/", "");
            data = data.replace("'./WorkOpt/", "");
            data = data.replace("'./WorkOpt/", "");
            data = data.replace("'./WorkOpt/", "");


            data = data.replace('@', '<br/>@');
            data = data.replace(/@/g, '<br/>&nbsp;@');

            data = data.replace('@', '<br/>@');
            data += " <center><input type='button' value='    关    闭    ' onclick='CloseAll();'  /></center>";

            $("#btns").attr("display", "block");

            $(".Msg").show();
            $(".Msg").html(data);

            $("#labInfo").empty();
            $("#next").empty();

            //  display

            //隐藏table.
            document.getElementById("Table1").style.display = "none";
            document.getElementById("TB_Emps").style.display = "none";
            document.getElementById("Btn_SelectEmps").style.display = "none";

            //document.getElementById("Btn_AddEmps").style.display = "none";

            var ctrl = document.getElementById("Btn_Send");
            if (ctrl != null)
                ctrl.style.display = "none";

            ctrl = document.getElementById("labInfo");
            if (ctrl != null)
                ctrl.style.display = "none";

            ctrl = document.getElementById("Btn_Close");
            if (ctrl != null)
                ctrl.style.display = "none";
        }

        //取消移交
        function CloseAll() {
            if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                window.parent.close();
            }
            window.close();
        }

        //设置选中的人员
        function selectEmpsWindowClose(data) {

            $('#selectEmpsModal').modal('hide');
            if (data == '取消') {
                return;
            }

            DoCC(frames["iframeSelectEmpsForm"].window.returnVal.No);
            return;
            $('#TB_Emps').val(frames["iframeSelectEmpsForm"].window.returnVal.No);
        }

        //删除当前行
        function delRow(nowTr) {
            //$(nowTr).parents("tr").remove();
            $("#Table1 tbody tr:eq(" + nowTr + ")").remove();
        }

        //得到行对象
        function ClearTable() {

            var table = $("#Table1");
            var tbody = $("#Table1 tbody");
            var trArr = $("#Table1 tbody tr");
            tbody.empty();
        }

        $(function () {

            //  $("#TB_Emps").plac
            //人员选择
            $("#TB_Emps").bind('input propertychange', function () {


                if ($("#TB_Emps").val() == null || $("#TB_Emps").val() == "") {
                    //alert("输入内容为空！");
                    //return;
                    $("#SelectEmp").hide().html("");
                    return;
                }

                //执行数据初始化工作.
                var hand = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
                hand.AddUrlData();
                hand.AddPara("TB_Emps", $("#TB_Emps").val());
                var data = hand.DoMethodReturnString("HuiQian_SelectEmps");
                if (data.indexOf('err@') == 0) {
                    alert(data);
                    return;
                }

                //SelectEmp
                //jQuery("#select_id").append("<option value='Value'>Text</option>");  

                data = JSON.parse(data);
                //$("#SelectEmp").hide().html("");
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    //$("#SelectEmp").append("<option value='" + data[i].No + "' onclick=selectAdd('" + data[i].No + "')>" + data[i].Name + "</option>");
                    html = html + "<div class='item' onclick='getCon(\"" + data[i].No + "\");' onmouseenter='getFocus(this)'>" + data[i].Name + "</div>";
                }
                $("#SelectEmp").show().html(html);

            });
        });

        function selectAdd(No) {
            DoCC(No);
        }

        //鼠标事件
        function getFocus(obj) {
            $(".item").removeClass("addbg");
            $(obj).addClass("addbg");
        }

        //选择下拉数据
        function getCon(no) {

            $("#TB_Emps").val('');

            DoCC(no);

            $("#SelectEmp").hide().html("");
        }

        function Help() {
            $("#HelpInfo").toggle();
        }
        function closeWin() {
            window.parent.returnWorkWindowClose("");
        }
    </script>
</head>
<body>
    <table id="Table1" style="width: 98%;">
        <thead>
            <tr id='title'>
                <th>名称</th>
                <th> 所在部门 </th>
                <th> 操作 </th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <br />
    <div>
        <div id="labInfo">
           输入关键字: <input type="text" id="TB_Emps"  title="查张三,您可输入: zs或zhangs或zhangsan"
         placeholder="查张三,您可输入:zs或zhangs或zhangsan"  name="TB_Emps" value='' style="width: 300px;" />
            <input type="button" id="Btn_SelectEmps" value='选择抄送人' />
            <br /><img src="../Img/CC.png"  style="width:27px;"/><a href="javascript:Help()">帮助</a>
            <div id="SelectEmp">
            </div>
            <br />
            <div id="next">
<!--
                <input type="button" id="Btn_CC" value="执行抄送" onclick="SaveAndClose();" />
                <img src="../Img/CC.png"  onclick="SaveAndClose();"  style="width:27px;"/>-->

                <div id="HelpInfo" style="">
                    <ul>
                        1、抄送就是把当前的工作抄送给其他人查阅，但是对方没有审批审核的权限。
                        <br />2、被抄送人，可以在抄送列表里查看抄送信息。
                        <br />3、可以使用人员名称拼音，支持全拼和简拼。
                        <br />例如:查找耿润华您可以输入: grh 或者 gengrh 或者 gengrunhua 
                        <br />支持单位名称，例如：耿润华/集团信息中心， 可以输入为 grh/jtxxzx 
                    </ul>
                </div>
            </div>
        </div>
        <div class="Msg" style="float: left;">
            <img src='../Img/loading.gif' alt="" />页面数据正在加载中，请稍候......</div>
    </div>
<br/>

    <div style="position: fixed; bottom: 0px; right: 0px;" class="foot">
    <input type="button" value="关闭" onclick="closeWin()"/>
    </div>
<!--

<section style="display: none;">
    <div>
        请选择要抄送的人：
        <input type="text" id="ToEmp" name="ToEmp" value='' style="width: 80%;"/> <input type="button" id="Btn_SelectEmps" value='选择接受人' style="position: relative; right: -562px; top: -41px; border-radius: 0px 25px 25px 0px; height: 27px;"/>
    </div>
    <div>
        抄送原因:
        <textarea name="Message" id="Message" style="vertical-align: top; width: 100%;"></textarea><br/>
    </div>
    <div style="margin: 20px auto;">
        <h5> 抄送模式:</h5>
        <input type="radio" value="0" name="RB_Model" checked=checked checked=checked id="RB_Model_0"/> <label for="RB_Model_0">抄送后直接发送给下一步处理人</label>
        <input type="radio" id="RB_Model_1" value="1" name="RB_Model"/> <label for="RB_Model_1">抄送后发送给我由我发送给下一步处理人</label>
    </div>
    <div style="position: fixed; bottom: 0px; right: 0px;" class="foot">
        <input type=button value="确定" onclick="DoCC();"/>
        <input type="button" id="" value="关闭" onclick="Close();"/>
    </div>
</section>-->
</body>
</html>
